package com.example.keli.ui.list;

import android.content.Context;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.keli.R;
import com.example.keli.base.utils.DensityUtil;
import com.example.keli.base.utils.GlideUtil;
import com.example.keli.base.utils.ScreenUtil;

import java.util.List;

/**
 * description:
 * author: Allen
 * date: 2019/3/19 11:51
 */
public class RankListAdapter extends BaseQuickAdapter<RankData.DataBean, BaseViewHolder> {

    int width = 173 * 2;
    int height = 220 * 2;
    LinearLayout.LayoutParams layoutParams;
    public RankListAdapter(List<RankData.DataBean> mData, Context context) {
        super(R.layout.item_rank_list, mData);
        width = (ScreenUtil.getScreenWidth(context) - DensityUtil.dip2px(context, 24));
        height = width * 150 / 351;
        layoutParams = new LinearLayout.LayoutParams(width,height);
        layoutParams.gravity= Gravity.CENTER_HORIZONTAL;
    }

    @Override
    protected void convert(BaseViewHolder helper, RankData.DataBean mListBean) {
        ImageView cover = helper.getView(R.id.cover);
        TextView time = helper.getView(R.id.time);
        TextView title = helper.getView(R.id.title);
        TextView status = helper.getView(R.id.status);
        RankItemLayout ticketLayout = helper.getView(R.id.ticket_layout);
        RankItemLayout giftLayout = helper.getView(R.id.gift_layout);
        ticketLayout.setTicketNum(mListBean.getTicketUser());
        giftLayout.setGiftNum(mListBean.getGiftUser());
        giftLayout.setIcon(R.mipmap.fans_icon);
        giftLayout.setIconTitle("粉丝榜");
        title.setText(mListBean.getTitle());

        ticketLayout.setMore(String.valueOf(mListBean.getId()),0);
        giftLayout.setMore(String.valueOf(mListBean.getId()),1);

        time.setText("截止时间："+mListBean.getEnd_time());
        GlideUtil.displayRound(cover.getContext(), cover, mListBean.getCover_picture(),5);
        cover.setLayoutParams(layoutParams);
//        helper.setText(R.id.city,"["+mListBean.getRegion_name()+"站]");

        switch (mListBean.getStatus()){
            case 1:
                status.setText("待启动");
                break;
            case 2:
                status.setText("报名中");
                break;
            case 3:
                status.setText("进行中");
                break;
            case 4:
                status.setText("已结束");
                break;
        }
    }

}
